<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:cc="http://xmlns.jcp.org/jsf/composite"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://xmlns.jcp.org/jsf/core">
    <cc:interface>
        <cc:attribute
            name = "componentToUpdate"
            required = "true"
            type = "java.lang.String" />
        <cc:attribute 
            name = "deleteButtonRendered"
            required = "true"
            type = "java.lang.Boolean" />
        <cc:attribute
            name = "eventController"
            required = "true"
            type = "assisisw.smartcal.webuisubsystem.managedbean.event.AbstractEventControllerBean" />
        <cc:attribute 
            name = "sharingFunctionalitiesEnabled"
            required = "true"
            type = "java.lang.Boolean" />
        <cc:attribute
            name = "widgetName"
            required = "true"
            type = "java.lang.String" />
    </cc:interface>
    <cc:implementation>
        <h:form 
            id = "eventForm"
            prependId = "false"
            rendered = "true" >
            <div class="genericTableRow" >
                <p:outputLabel 
                    for = "eventViewNameField" 
                    id = "eventViewNameLabel" 
                    rendered = "true" 
                    transient = "true"
                    value = "Event name :"/>
                <p:inputText 
                    id = "eventViewNameField" 
                    maxlength = "25"
                    readonly="#{not cc.attrs.eventController.editAllowed}"
                    rendered = "true" 
                    value="#{cc.attrs.eventController.managedEvent.name}"/>
            </div>
            <div class="genericTableRow" >
                <p:outputLabel 
                    for = "eventViewIniDateCalendar" 
                    id = "eventViewIniDateLabel" 
                    rendered = "true" 
                    transient = "true"
                    value = "Event ini date :" />
                <p:calendar  
                    disabled="#{not cc.attrs.eventController.editAllowed}"
                    disabledWeekends = "false"
                    id = "eventViewIniDateCalendar" 
                    navigator = "true"   
                    pattern = "MM/dd/yyyy HH:mm"
                    readonly = "#{not cc.attrs.eventController.editAllowed}"
                    readonlyInput="#{not cc.attrs.eventController.editAllowed}"
                    rendered = "true" 
                    value="#{cc.attrs.eventController.managedEvent.iniDate}"/>
            </div>
            <div class="genericTableRow" >
                <p:outputLabel 
                    for ="eventViewEndDateCalendar" 
                    id = "eventViewEndDateLabel"
                    transient = "true" 
                    value = "Event end date :" />
                <p:calendar 
                    disabled="#{not cc.attrs.eventController.editAllowed}"
                    disabledWeekends = "false"
                    id = "eventViewEndDateCalendar"
                    navigator = "true"
                    pattern = "MM/dd/yyyy HH:mm"
                    readonly = "#{not cc.attrs.eventController.editAllowed}"
                    readonlyInput="#{not cc.attrs.eventController.editAllowed}"
                    rendered = "true" 
                    value = "#{cc.attrs.eventController.managedEvent.endDate}" >
                    <p:ajax 
                        async="true"
                        delay="none"
                        disabled="false"
                        event="dateSelect"
                        listener="#{cc.attrs.eventController.onDateSelected }"
                        partialSubmit="true"
                        process="@form"/>
                </p:calendar>
            </div>
            <div class = "genericTableRow">
                <p:panel id = "timeConsistencyText" widgetVar="timeConsistencyText">
                    <h:outputLabel value="#{cc.attrs.eventController.timeConsistencyInfo}"/>
                </p:panel>
            </div>
            <div class="genericTableRow" >
                <p:outputLabel 
                    for = "eventViewIsOutdoorCheckBox" 
                    id = "eventViewIsOutdoorLabel" 
                    transient = "true" 
                    value = "Is outdoor ?"/>
                <p:selectBooleanCheckbox 
                    disabled = "#{not cc.attrs.eventController.editAllowed}"
                    id = "eventViewIsOutdoorCheckBox"
                    rendered = "true" 
                    value="#{cc.attrs.eventController.managedEvent.outdoor}" />
            </div>
            <div class="genericTableRow" >
                <p:outputLabel 
                    for = "eventViewPlaceField" 
                    id = "eventViewPlaceLabel" 
                    value = "Event place :" />
                <p:inputText 
                    id = "eventViewPlaceField" 
                    maxlength = "25"
                    readonly = "#{not cc.attrs.eventController.editAllowed}"
                    value = "#{cc.attrs.eventController.managedEvent.place}">
                    <p:ajax 
                        async = "true"
                        disabled = "false"
                        event = "valueChange"
                        listener = "#{cc.attrs.eventController.updateWeather ()}"
                        partialSubmit = "true"
                        process = "@this"
                        update = "eventWeatherPanel" />
                </p:inputText>
                <p:panel id = "eventWeatherPanel" widgetVar = "eventWeatherPanel" >
                    <p:inputText
                        disabled="false"
                        id = "eventViewWeatherInfoDataOutputText" 
                        readonly="true" 
                        rendered = "#{cc.attrs.eventController.weatherInfoAvailable}"
                        value = "#{cc.attrs.eventController.managedEvent.weatherInfo}" />
                </p:panel>
            </div>
            <div class="genericTableRow" >
                <p:outputLabel  
                    id = "eventViewVisibilityLabel" 
                    rendered = "true"
                    transient = "true" 
                    value = "Visibility :" />
                <p:selectOneMenu 
                    disabled="#{not cc.attrs.eventController.editAllowed}"
                    id = "eventViewEventVisibility"
                    value="#{cc.attrs.eventController.managedEvent.visibility}">
                    <f:selectItems 
                        value="#{cc.attrs.eventController.visibilities}"/>
                </p:selectOneMenu>
            </div>
            <div class="genericTableRow" >
                <p:outputLabel 
                    id = "eventViewOwningCalendarLabel"
                    rendered = "true"  
                    transient = "true" 
                    value = "Calendar :" />
                <p:selectOneMenu 
                    disabled = "#{not cc.attrs.eventController.editAllowed}"
                    id = "eventViewCalendarsList"
                    value="#{cc.attrs.eventController.selectedCalendarId}" >
                    <f:selectItems
                        itemLabel="#{calendar.name}"
                        itemValue="#{calendar.id}" 
                        value="#{cc.attrs.eventController.availableCalendars}" 
                        var ="calendar" >
                    </f:selectItems>
                </p:selectOneMenu>
            </div>
            <p:panel
                id = "eventViewEventSharingBox"
                rendered = "#{cc.attrs.sharingFunctionalitiesEnabled}" >
                <div class="genericTableRow" >
                    <p:dataScroller 
                        id = "peopleWhoCanAccessTheEventDataScroller" 
                        value = "#{cc.attrs.eventController.managedEvent.invitedUsers}"
                        var = "user"
                        widgetVar="peopleWhoCanAccessTheEventDataScroller" >
                        <f:facet name = "header">
                            Invited People
                        </f:facet>
                        <h:form>
                            <p:commandLink value="#{user.mail}" />
                        </h:form>
                    </p:dataScroller>
                </div>
                <div class="genericTableRow" >
                    <p:panel rendered="#{cc.attrs.eventController.editAllowed}">
                        <p:outputLabel 
                            for = "eventViewNewUserWhoCanAccessField" 
                            id = "eventViewNewUserWhoCanAccessLabel" />
                        <p:inputText 
                            id = "eventViewNewUserWhoCanAccessField" 
                            maxlength = "20"
                            value = "#{cc.attrs.eventController.newSharedMail}" />
                        <p:commandButton 
                            id = "newEventSharingButton"
                            type = "submit"
                            value = "Share !" >
                            <p:ajax 
                                async = "true"
                                disabled = "false" 
                                event = "click" 
                                immediate = "true" 
                                listener = "#{cc.attrs.eventController.newShareAction ()}" 
                                update = "peopleWhoCanAccessTheEventDataScroller" />
                        </p:commandButton>
                    </p:panel>
                </div>
            </p:panel>
            <div class="genericTableRow" >
                <p:commandButton 
                    id = "eventViewDeleteEventButton"
                    onclick="PF('#{cc.attrs.widgetName}').hide()"
                    rendered = "#{cc.attrs.deleteButtonRendered and cc.attrs.eventController.editAllowed}"
                    type = "submit"
                    value="Delete">
                    <p:ajax 
                        async = "true"
                        disabled = "false"
                        event = "click"
                        immediate = "true"
                        listener = "#{cc.attrs.eventController.deleteAction ()}"
                        oncomplete = "PF('#{cc.attrs.componentToUpdate}').update()"
                        partialSubmit = "true"
                        process = "@form" />
                </p:commandButton>
                <p:commandButton 
                    id = "eventViewConfirmEventButton"
                    onclick="PF('#{cc.attrs.widgetName}').hide()"
                    rendered = "#{cc.attrs.eventController.editAllowed}" 
                    type = "submit" 
                    value="Ok" >
                    <p:ajax 
                        async = "true"
                        disabled = "false"
                        event = "click"
                        immediate = "true"
                        listener = "#{cc.attrs.eventController.confirmAction ()}"
                        oncomplete = "PF('#{cc.attrs.componentToUpdate}').update()"
                        partialSubmit = "true"
                        process = "@form" />
                </p:commandButton>
            </div>
        </h:form>
    </cc:implementation>
</html>